<?php
namespace App\SMS;

class SendTemplateSMS{
    //主账号
    private $accountSid= '8a216da877bef0fe0177fd3adb1617ed';
    //主账号token
    private $accountToken = 'c5b90d168e6d4bb8aa84bd7c85831a41';
    //应用id
    private $appId= '8a216da877bef0fe0177fd3adc0b17f3'; 
    //请求地址
    private $serverIP='app.cloopen.com';
    //请求端口
    private $serverPort='8883';
    //REST版本号
    private $softVersion='2013-12-26';

    public function sendTemplateSMS($to,$datas,$type){
        $m3_result = new M3Result;

        $rest = new CCPRestSDK($this->serverIP,$this->serverPort,$this->softVersion);
        $rest->setAccount($this->accountSid,$this->accountToken);
        $rest->setAppId($this->appId);

        //发送模板短信
        $result = $rest->sendTemplateSMS($to,$datas,$type);
        if($result == NULL){
            $m3_result -> status = 3;
            $m3_result -> message = 'result error!';
        }
        if($result -> statusCode != 0){
            $m3_result -> status = $result -> statusCode;
            $m3_result -> message = $result -> statusMsg;
        }else{
            $m3_result -> status = 0;
            $m3_result -> message = '发送成功';
        }
        return $m3_result;
    }
}